Powershell
Get-process
Get-service
get-help md
ls -Path HKLM:\HARDWARE
# sql like
Get-process | where handels -gt 900 | sort handels
Get-service | select -property name, status
# output
Tree | out-file j:\main.html
| ConvertTo-html | out-file j:\main.html
# vars
$location = Get-Location
# if
if($x -le 20){
write-host("This is if statement")
}else {
write-host("This is else statement")
}
# for loop
for($i = 0; $i -lt $array.length; $i++){
$array[$i]
}
# while loop
while($counter -lt $array.length) {
$array[$counter]
}
# for each loop
$array = @("item1", "item2", "item3")
$A = 1, 2, 3, 4
foreach ($element in $array) { $element }
$array | foreach { $_ }
# regex
"book" -match "oo"
"and" -match "[^brt]nd"
# function
function Verb-Noun {
param (
# static parameters
)
dynamicparam {
# dynamic parameters
}
begin {
# start of the pipeline
}
process {
# ran for each item in the pipeline
}
end {
# end of the pipeline
}
}